export function deleteHandler(str, id) {
    const deleteNoteURL = '/notes/deleteNoteByNid';
    const deleteTodoURL = '/todos/deleteTodoByTid';
    if (str === 'note') {
        let nid = id;
        axios.delete(`${deleteNoteURL}/${nid}`).then(res => {
            console.log(res);
            if (res.data.ok === 1) {
                Qmsg.success('删除成功！');
                window.setTimeout(function () {
                    window.location.reload();
                }, 500)
            } else {
                Qmsg.error('删除失败！');
            }
        }).catch(error => {
            alert(error);
        })
    } else if (str === 'todo') {
        let tid = id;
        axios.delete(`${deleteTodoURL}/${tid}`).then(res => {
            console.log(res);
            if (res.data.ok === 1) {
                Qmsg.success('删除成功！');
                let parentNode = document.getElementById(`td${tid}`).parentNode;
                $(parentNode).css('display', 'none');
            } else {
                Qmsg.error('删除失败！');
            }
        }).catch(error => {
            alert(error);
        })
    }
}